package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOPeration{

    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书!");
        System.out.println("请输入您要查找的图书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int currentSize = bookList.getUsedSize();//通过调用bookList中的get语句获取userSize值
        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            //判断
            if(book.getName().equals(name)) {
                System.out.println(book);
                return;
            }
            //查找
        }
        System.out.println("不存在该书" + name);
    }
}
